<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
	.errorLabel {
		border-color: red;
		color: red;
	}
	.required {
		font-weight: bold;
	}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><s:text name="welcome.title" /></title>
</head>
<body>
	<p>
		<s:text name="productcreator.title" />
	</p>
	<p>
		<s:form  action="ProductCreator_forward">
			<s:textfield name="name" key="product.name" size="20" required="true" />
			<s:textarea name="description" key="product.description" rows="5" cols="50" required="true"></s:textarea>
			<s:textfield name="stock" key="product.stock" size="20" required="true" />
			<s:textfield name="price" key="product.price" size="20" required="true" />
			<s:textfield name="deliveryTime" key="product.deliveryTime" size="20" required="true" />
			<s:select name="categoryId" key="product.category" list="%{categoryList}" listKey="categoryId"
				listValue="name" required="true" headerKey="-1" headerValue="" />
			<s:submit key="button.add" />
			<s:hidden name="productDataPosted" value="true" />
		</s:form>
	</p>
	
	<s:a action="ProductCreator_backwards"><s:text name="button.back" /></s:a>
	
	<font color="red">
		<s:actionerror label="label" />
	</font>
	
	<p>
		<b><s:text name="productcreator.products" />:</b><br />
		<table width="100%" border="0" cellpadding="5">
			<s:iterator value="categoryList">
				<tr>
					<th colspan="7" bgcolor="#888888">
						<b><s:property value="name"/></b>
					</th>
				<tr>
				<tr bgcolor="#AAAAAA">
					<td bgcolor="#FFFFFF">&nbsp;</td>
					<td align="center"><b><i>&lt;<s:text name="product.name" />&gt;</i></b></td>
					<td align="center"><b><i>&lt;<s:text name="product.description" />&gt;</i></b></td>
					<td align="center"><b><i>&lt;<s:text name="product.stock" />&gt;</i></b></td>
					<td align="center"><b><i>&lt;<s:text name="product.price" />&gt;</i></b></td>
					<td align="center"><b><i>&lt;<s:text name="product.deliveryTime" />&gt;</i></b></td>
					<td align="center"><b><i>&lt;<s:text name="button.delete" />&gt;</i></b></td>
				</tr>
				
				<s:iterator value="products" status="rowstatus">				
					 
					<s:if test="#rowstatus.odd == true">
							<tr bgcolor="#CCCCCC">
						<s:else>
							<tr bgcolor="EEEEEE">
						</s:else>
					</s:if>
						<td width="3%" bgcolor="FFFFFF">&nbsp;</td>
						<td width="25%">
							<b><s:property value="name" /></b>
						</td>
						<td width="32%">
							<s:property value="description" />
						</td>
						<td width="10%" align="center">
							<s:property value="stock" />
						</td>
						<td width="10%" align="center">
							<s:property value="price" />
						</td>
						<td width="10%" align="center">
							<s:property value="deliveryTime" />
						</td>
						<td width="10%" align="center">
							<s:form action="ProductDelete" theme="simple">
								<s:submit  key="button.delete" />
								<s:hidden name="productId" value="%{productId}" />
							</s:form>
						</td>
					</tr>
					
				</s:iterator>
			</s:iterator>
		</table>
	</p>
</body>
</html>